<?php
	/**
	*	基于mysqli 数据库操作类
	*/
	class Dbconn{
		public $conn,$result;

		//创建连接
		function __construct($dbhost,$dbuser,$dbpw,$dbname,$charset){
			$this->conn = mysqli_connect($dbhost,$dbuser,$dbpw,$dbname) or die(mysql_error());
			mysqli_query($this->conn,"SET NAMES $charset") or die(mysql_error());
		}

		//查询语句
		function getquery($sql){
			return mysqli_query($this->conn,$sql);
		}

		//关联数组
		function fetch_array($result){
			return mysqli_fetch_array($result);
		}

		//查询条数
		function fetch_num($result){
			return mysqli_num_rows($result);
		}

		//获取mysql版本
		function mysqli_getinfo(){
			return mysqli_get_server_info($this->conn);
		}


		//查询一条数据
		function fetch_assoc($result){
			return mysqli_fetch_assoc($result);
		}

		//析构函数 关闭mysql连接
		function __destruct(){
			mysqli_close($this->conn);
		}
	}
?>
